package 算法;

public class 查找缺失的数字 {
    public static void main(String[] args) {
        System.out.println(missingNumber(new int[]{0,1,2,4,5,6,7}));
    }
    public int game(int[] guess, int[] answer) {
        int res = 0;
        for (int i = 0; i < guess.length; i++) {
            if(guess[i] == answer[i]) res++;
        }
        return res;
    }
    public static int missingNumber(int[] nums) {
        //关系[l,r)
        int l = 0,r = nums.length;
        while (r-l!=1){
            int mid = l + (l+r)/2;
            if(nums[mid] == mid+1) l = mid;
            else r = mid;
        }
        return r;
    }
}
